#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include "ffmpegkits.h"
#include "cameracontrolrequest.h"
#include <QWidget>
#include <memory>
#include <QNetworkAccessManager>

using std::unique_ptr;

QT_BEGIN_NAMESPACE
namespace Ui { class MainWidget; }
QT_END_NAMESPACE

enum PLAYER_STATE {
    PLAYER_IDLE = 0,
    PLAYER_PLAYING,
    PLAYER_PAUSE,
    PLAYER_STOP
};

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    MainWidget(QWidget *parent = nullptr);
    ~MainWidget();

    void paintEvent(QPaintEvent *event) override;

private slots:
    void getOneFrame(QImage image);

    void on_playButton_clicked();

    void on_pauseButton_clicked();

    void on_flipButton_clicked();

    void on_leftButton_clicked();

    void on_rightButton_clicked();

    void on_upButton_clicked();

    void on_downButton_clicked();

    void on_leftUpButton_clicked();

    void on_rightUpButton_clicked();

    void on_leftDownButton_clicked();

    void on_rightDownButton_clicked();

private:
    void cameraControl(enum MoveCommand command);

private:
    Ui::MainWidget *ui;
    unique_ptr<FFmpegKits> _pFfmpegKits;
    QImage _image;
    PLAYER_STATE _kPlayState;
    bool _hFlip; // 水平翻转
    bool _vFlip; // 垂直翻转
    unique_ptr<QNetworkAccessManager> _pHttpManager;
};
#endif // MAINWIDGET_H
